﻿using CharacterCreation.Views.Contracts;
using CharacterCreation.Data.Models;
using CharacterCreation.Data.Services;
using System.Windows.Media;

namespace CharacterCreation.Views {
    /// <summary>
    /// The viewmodel 
    /// </summary>
    public class RaceDetailViewModel : BaseViewModel {

        RaceService _raceService = RaceService.CreateInstance();

        /// <summary>
        /// The foreground brush
        /// </summary>
        public SolidColorBrush ForegroundBrush {
            get {
                if (!IsNewItem)
                    return new SolidColorBrush(Colors.White);
                else
                    return new SolidColorBrush(Colors.Black);
            }
        }

        /// <summary>
        /// Current race
        /// </summary>
        public Race Race {
            get {
                if (!IsNewItem)
                    return _raceService.CurrentItem;
                else
                    return _raceService.NewItem;
            }
        }

        public RaceDetailViewModel() {
            _raceService.PropertyChanged += (s, e) => {
                if (e.PropertyName == "CurrentItem")
                    RaisePropertyChanged("Race");
            };
        }
    }
}
